package com.red.star.macalline.data.mappers;

import com.red.star.macalline.data.core.base.MyMapper;
import com.red.star.macalline.data.entity.StoredCard;
import com.red.star.macalline.data.entity.SuperPojo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author
 * @Description:蓄客卡Mapper
 * @create 2018-02-27 19:31
 **/
public interface StoredCardMapper extends MyMapper<StoredCard> {

	public void addCardAndgroup(@Param("id") Integer id, @Param("groupId") Integer groupId);

	public void updateCardAndgroup(@Param("id") Integer id, @Param("cId") Integer cId, @Param("groupId") Integer groupId);

	public void doUpdate(StoredCard storedCard);

	public List<StoredCard> queryByStoredCards(StoredCard storedCard);

	public List<StoredCard> getAllStoredCard(@Param("mallCode") String mallCode);

	public void updateDeleteGroupById(@Param("id") Integer id);

	public void changeStatusById(@Param("id") Integer id);

	public StoredCard findOne(@Param("id") Integer id);

	public void changeStatusById(@Param("id") Integer id, @Param("status") Integer status);

	public List<SuperPojo> queryStoredAndMallAndEmployAndMerchant(SuperPojo superPojo);

	public List<SuperPojo> queryStoredAndVipAndFansCardAndMallAndMerchant(SuperPojo superPojo);

	public List<SuperPojo> queryMallAndEmployAndMerchantAndFans(SuperPojo superPojo);

	@Select(value = "select * from t_stored_card where name =#{name} and mall_code = #{mallCode}")
	public StoredCard getStoredCardByNameAndMallCode(@Param("name") String name, @Param("mallCode") String mallCode);

	@Select("select t.name from t_stored_card t order by convert(t.name using gbk) collate gbk_chinese_ci asc")
	public List<String> findNameList();

	@Select(value = "select DISTINCT t.coupons_package_id from t_stored_card t where (NOW() BETWEEN t.start_time and t.end_time) and t.status = 1")
	public List<Integer> findOnlyEffectiveMallCode();

    StoredCard findLastByFansAndGroup(@Param("cFansId") Integer cFansId, @Param("groupId") Integer groupId);
}
